import asyncio
import json

from fastmcp import Client

# Create a standard MCP configuration with multiple servers
config = {
    "mcpServers": {
        # A local MCP server
        "printer": {
            "url": "http://localhost:8000/mcp",
            "transport": "streamable-http"
        }
    }
}

# Create a client that connects to both servers
client = Client(config)


async def main():
    async with client:
        # 客户端调用MCP Server工具
        # 调用生成背景图片的工具
        params = {
            "description": "A serene landscape with mountains and a river",
            "negative_describe": "红色元素",
            "num": 1,
            "style": "realistic",
            "size": '1024*1024'
        }
        result = await client.call_tool("generate_background_image", params)
        print(f"生成的图片: {result}")

async def xx():
    async with client:
        tools=await client.list_tools()
        for chunk in tools:
            print(chunk,"||")


if __name__ == "__main__":
    asyncio.run(main())